package com.csj.lc.controller;

import com.csj.lc.base.BaseController;
import com.csj.lc.entity.HardwareParameterBean;
import com.csj.lc.entity.dto.ReturnDTO;
import com.csj.lc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/")
public class LoginController extends BaseController {

    @RequestMapping(value={"","index"})
    public String index(){
       return "login";
    }

    @RequestMapping(value = "login", method = RequestMethod.POST)
    public ModelAndView login(HttpServletRequest request, User user){
       return loginService.login(request,user);
    }

    @RequestMapping(value = "csLogin", method = RequestMethod.POST)
    @ResponseBody
    public ReturnDTO<User> csLogin(HttpServletRequest request, User user){
        return loginService.csLogin(request,user);
    }

    @RequestMapping("home")
    public String home(HttpServletRequest request, Model model){

        return loginService.home(request,model);
    }

    @RequestMapping(value = "welcome")
    public String login(HttpServletRequest request){
        return "welcome";
    }

    @RequestMapping("logout")
    public String logout(HttpServletRequest request){

        return loginService.logout(request);
    }

}
